package org.scau.studentevaluation.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.scau.studentevaluation.config.global.log.WebLog;
import org.scau.studentevaluation.entity.query.ActExistQuery;
import org.scau.studentevaluation.entity.query.AttendedStudentListQuery;
import org.scau.studentevaluation.entity.vo.AttendedStudentVO;
import org.scau.studentevaluation.service.IAttendedStudentListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api("AttendedStudentList控制器")
@WebLog("AttendedStudentList控制器")
public class AttendedStudentListController {

    @Autowired
    private IAttendedStudentListService attendedStudentListService;

    @ApiOperation("通过活动id获取活动的学生")
    @GetMapping("/getActStudents/{actId}")
    public List<AttendedStudentVO> getActStudentsByActId(Long actId){
        return attendedStudentListService.getActStudentsByActId(actId);
    }

    @ApiOperation("删除一个活动的所有学生，返回删除数量")
    @DeleteMapping("/deleteStudents/{actId}")
    public int deleteStudentsByActId(Long actId){
        return attendedStudentListService.deleteStudentsByActId(actId);
    }

    @ApiOperation("通过学生id获取学生参加的活动id")
    @GetMapping("/getActIDs/{studentId}")
    public List<Long> getActIdsByStudentId(Long studentId){
        return attendedStudentListService.getActIdByStudentId(studentId);
    }

    @ApiOperation("通过college获取活动id")
    @GetMapping("/getActIDsByCollege/{college}")
    public List<Long> getActIdsByCollege(String college){
        return attendedStudentListService.getActIdByCollege(college);
    }

    @ApiOperation("判断指特定学生和活动的数据是否存在（1存在，0不存在）")
    @GetMapping("/actExist")
    public int ActExist(ActExistQuery actExistQuery){
        return attendedStudentListService.actExist(actExistQuery);
    }



    @ApiOperation("插入活动参加的学生")
    @PostMapping("/InsertAttendedStudent")
    public int InsertAttendedStudent(@RequestBody List<AttendedStudentListQuery> queryList){
        return attendedStudentListService.InsertAttendedStudent(queryList);
    }


}
